<?php

namespace app\core\controller;

use think\Controller;


class Addon extends Controller
{

    public function initialize()
    {
        parent::initialize();
    }

    /**
     * 渲染插件内容
     * @param string $temp
     * @return mixed
     */
    public function addonFetch($temp = '')
    {
        if (empty($temp)) {
            $trace = debug_backtrace(false, 2);
            $functionname = $trace[1]['function'];
            $class = $trace[1]['class'];
            $l = explode('\\', $class);
            return $this->fetch("../addon/{$l[1]}/view/" . strtolower($l[3]) . "/" . strtolower($functionname) . ".html");
        } else {

            if (strpos($temp, '/') === false) {
                $trace = debug_backtrace(false, 2);
                $class = $trace[1]['class'];
                $l = explode('\\', $class);
                return $this->fetch("../addon/{$l[1]}/view/" . strtolower($l[3]) . "/" . strtolower($temp) . ".html");
            }


            //../addon/weiboLogin/view/index/aaa.html
            return $this->fetch($temp);
        }


    }


}
